#include <linux/init.h>
#include <linux/kernel.h>
#include <linux/cpu.h>
#include <linux/sched.h>
#include <linux/sched/task.h>
#include <linux/sched/init.h>

#include <linux/irqflags.h>

#include <linux/delay.h>

static void __noreturn rest_init(void)
{
    extern void kernel_init_startup(void);

    kernel_init_startup();

    /*
     * The boot idle thread must execute schedule()
     * at least once to get things moving:
     */
    schedule_preempt_disabled();

    /* Call into cpu_idle with preempt disabled */
    cpu_startup_entry(CPUHP_ONLINE);
}

__weak void init_task_setup(void)
{
    /* Initialize task::filedesc etc */
}

__weak void smp_setup_processor_id(void)
{
}

void start_kernel(void)
{
    smp_setup_processor_id();

    local_irq_disable();

    setup_arch(0);

    call_early_init();

    sched_init();

    init_task_setup();

    init_IRQ();
    init_timers();
    time_init();

    kthread_daemon_init();

    rest_init();
}
